﻿<%@ WebHandler Language="C#" Class="SendHouseInfo" %>

using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Web;
using System.IO;
using System.Data;
using System.Web.Script.Serialization;
using System.Collections.Generic;
using System.Data.SqlClient;
using Chenxin.Lib.Utility;
using Chenxin.Lib.House.Entity;


public class SendHouseInfo : AjaxHandlerBase
{
    private Encoding myEncoding = Encoding.GetEncoding("utf-8");
    private string domain = "http://api.anjuke.com/1.0/rest";  //api.sandbox.anjuke.com/rest
    private string apiKey = "&apikey=ZlblIXvIDoy34kjgcdZgcTl&token=TOKEN123456&sign=de6fda102257c51a3deeda5b8d6d674e";
    //private string apiKey = "&apikey=ajktest&token=ajktest&sign=66bb95875ce0cfaf1a839ff0367fe65f";
    private string user_id = "";
    private string comm_id = "";
    private JavaScriptSerializer serializer = new JavaScriptSerializer();
    private string result = "";
    override public void RequestProcess(HttpContext context)
    {

        context.Response.ContentType = "text/plain";
        context.Response.Buffer = true;
        context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        Chenxin.Lib.House.Entity.House_BaseInfo model = null;

        if (context.Request["op"] == "Community")    //安居客 获取所选房源的类似房源
        {
            model = (Chenxin.Lib.House.Entity.House_BaseInfo)JsonHelp.Convert2Entity(context.Request["CommunityName"], typeof(Chenxin.Lib.House.Entity.House_BaseInfo));
            this.GetHouseForAJK(model, context);
        }
        if (context.Request["op"] == "add")       //安居客 推送房源
        {
            model = (Chenxin.Lib.House.Entity.House_BaseInfo)JsonHelp.Convert2Entity(context.Request["HouseInfo"], typeof(Chenxin.Lib.House.Entity.House_BaseInfo));
            this.SendHouseToAJK(model, context);
        }
        if (context.Request["op"] == "Sina_Add")      //房友在线推送房源
        {
            model = (Chenxin.Lib.House.Entity.House_BaseInfo)JsonHelp.Convert2Entity(context.Request["SinaHouseInfo"], typeof(Chenxin.Lib.House.Entity.House_BaseInfo));
            if (context.Request["SinaUserId"] == "undefined")
            {
                context.Response.Write("{success:'0',msg:'请输入用户ID',data:''}");
                return;
            }
            if (context.Request["SinaHouseTitle"] == "undefined")
            {
                context.Response.Write("{success:'0',msg:'请输入房源标题',data:''}");
                return;
            }
            this.SendHouseToSinaFYZX(model, context);
        }
        if (context.Request["op"] == "CityReHouse_Add")       //易居臣住推送房源
        {
            model = (Chenxin.Lib.House.Entity.House_BaseInfo)JsonHelp.Convert2Entity(context.Request["CityReHouseHouseInfo"], typeof(Chenxin.Lib.House.Entity.House_BaseInfo));
            if (context.Request["CityReHouseUserId"] == "undefined" || context.Request["CityReHouseHousePwd"] == "undefined")
            {
                context.Response.Write("{success:'0',msg:'请输入用户ID和密码',data:''}");
                return;
            }
            if (context.Request["CityReHouseHouseTitle"] == "undefined")
            {
                context.Response.Write("{success:'0',msg:'请输入房源标题',data:''}");
                return;
            }
            try
            {
                string result = Execue(System.Configuration.ConfigurationManager.AppSettings["CityReHouseApi"], "", this.BuildCityReHouseDic(model, context.Request["CityReHouseUserId"], context.Request["CityReHouseHousePwd"], context.Request["CityReHouseHouseTitle"]));
                Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(result);
                if (json["success"].ToString() == "1")
                {
                    //this.AddCItyReHouseInfo(model, context);
                    this.RecodSendLog(model.HouseId, model.HouseCode, model.Address, model.OprPersonId, model.OprDepartId,
                        CurrentUserInfo.UserId, CurrentUserInfo.DepartId, "易居臣信", "http://www.cityrehouse.com.cn", "", "");
                }
                context.Response.Write(result);
            }
            catch
            {
                context.Response.Write("{success:'0',msg:'推送失败,建议到CityReHouse手工推送',data:''}");
                return;
            }
        }
    }

    /// <summary>
    /// 获取安居客相关数据
    /// </summary>
    /// <param name="model"></param>
    /// <param name="context"></param>
    private void GetHouseForAJK(Chenxin.Lib.House.Entity.House_BaseInfo model, HttpContext context)
    {
        string cummunityName = model.Community;  //小区名
        string comm_url = "/search/communities/" + cummunityName + "?json" + apiKey;
        comm_id = GetCommidOrUserid(domain, comm_url, "community");
        context.Response.Write(comm_id);
    }

    /// <summary>
    /// 发送房源至安居客
    /// </summary>
    /// <param name="model"></param>
    /// <param name="context"></param>
    private void SendHouseToAJK(Chenxin.Lib.House.Entity.House_BaseInfo model, HttpContext context)
    {
        string adjCummId = context.Request["HouseSend"];  //"170170"; //
        string tel = context.Request["houseSendtxt_AJK_Tel"];
        string house_title = context.Request["txtAJK_Title"];
        if (adjCummId == "" || adjCummId == null || adjCummId == "undefined")
        {
            context.Response.Write("{success:'0',msg:'请选择',data:''}");
            return;
        }
        string user_url = "/brokers?mobile=" + tel + "&json" + apiKey;
        user_id = GetCommidOrUserid(domain, user_url, "broker");  //"2287";// "30"; // 
        if (user_id == "error")
        {
            context.Response.Write("{success:'0',msg:'未找到经纪人',data:''}");
            return;
        }
        Dictionary<string, string> dicAjk = this.GetAjkHouseIdBySendLog(model.HouseId.ToString(), adjCummId);
        string house_url = "";
        if (dicAjk.Count == 0)
        {
            house_url = "/properties/add?json" + apiKey;
        }
        else
        {
            house_url = "/properties/under/" + dicAjk["AjkHouseId"] + "?brokerid=" + user_id + "&json" + apiKey;
            string deleteResult = GetCommidOrUserid(domain, house_url, "deleteProid");
            Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(deleteResult);
            object stuats = json["status"];
            if (stuats.ToString() == "ok")
            {
                Chenxin.Lib.House.BLL.HouseSendLog.Delete("HouseId='" + model.HouseId.ToString() + "' and SendTarget='安居客' and SendAjkReturnHouseId='" + dicAjk["AjkHouseId"] + "' and SendAjkReturnCummId='" + dicAjk["AjkCummId"] + "' ");
                house_url = "/properties/add?json" + apiKey;
            }
            else
            {
                context.Response.Write("{success:'0',msg:'下架房源失败',data:''}");
                return;
            }
        }
        if (model.BusinessKind.Value == 30)  //如为租售,则要进行出售和出租推送操作
        {
            result = Execue(domain, house_url, InsertHouseInfo(model, user_id, adjCummId, 10, house_title));
            result = Execue(domain, house_url, InsertHouseInfo(model, user_id, adjCummId, 20, house_title));
        }
        else
        {
            result = Execue(domain, house_url, InsertHouseInfo(model, user_id, adjCummId, model.BusinessKind.Value, house_title));
        }
        this.UploadHousePic(model, context, result, adjCummId);
    }


    /// <summary>
    /// 安居客上传房源图片
    /// </summary>
    private void UploadHousePic(Chenxin.Lib.House.Entity.House_BaseInfo model, HttpContext context, string result, string cummId)
    {
        string pic_url = "/photos/upload?json" + apiKey;
        Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(result);
        object value;
        object err_Msg;
        if (json.TryGetValue("status", out value))
        {
            string rr = value.ToString();
            if (rr == "ok")
            {
                Dictionary<string, object> proid_obj = (Dictionary<string, object>)json["ActionResult"];
                object proid = proid_obj["proid"];
                this.RecodSendLog(model.HouseId, model.HouseCode, model.Address, model.OprPersonId, model.OprDepartId,
                    CurrentUserInfo.UserId, CurrentUserInfo.DepartId, "安居客", "http://shanghai.anjuke.com/", proid.ToString(), cummId);
                IDictionary ic = new Hashtable();
                ic.Add("broker_id", user_id);
                ic.Add("prop_id", proid.ToString());
                ic.Add("photo_type", "2");
                string pci_result = "";
                try
                {
                    string rootPicUrl = Constants.DIRECTORY;
                    List<House_PicturesInfo> pic_list = Chenxin.Lib.House.DAL.House_PicturesInfo.GetListArray("HouseId='" + model.HouseId.ToString() + "'");
                    foreach (House_PicturesInfo pic in pic_list)
                    {
                        switch (pic.PicType)
                        {//1=小区照片,2=房源照片 3 房型图
                            case "房型图":
                                ic["photo_type"] = "3";
                                break;
                            case "室内图":
                                ic["photo_type"] = "2";
                                break;
                            case "室外图":
                                ic["photo_type"] = "1";
                                break;
                        }
                        string upload_Pic = context.Server.MapPath(rootPicUrl + pic.MarkedUrl);
                        pci_result = UploadPic(domain + pic_url, upload_Pic, ic);
                    }
                }
                catch (Exception err)
                {
                    result = "{success:'0',msg:'推送失败 (" + err.Message + ")',data:''}";
                    context.Response.Write(result);
                    return;
                }
                if (pci_result == "")
                {
                    result = "{success:'1',msg:'房源推送成功 (图片上传失败)',data:''}";
                }
                else
                {
                    json = (Dictionary<string, object>)serializer.DeserializeObject(pci_result);
                    if (json.TryGetValue("status", out value))
                    {
                        if (value.ToString() == "ok")
                        {
                            result = "{success:'1',msg:'推送成功',data:''}";
                        }
                        else
                        {
                            if (json.TryGetValue("error", out value))
                            {
                                Dictionary<string, object> pic_err = (Dictionary<string, object>)value;
                                if (pic_err.TryGetValue("message", out err_Msg))
                                {
                                    result = "{success:'0',msg:'房源推送成功 (图片上传失败)  " + err_Msg.ToString() + "',data:''}";
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (json.TryGetValue("message", out err_Msg))
                {
                    result = "{success:'0',msg:'" + err_Msg.ToString() + "',data:''}";
                }
            }
        }
        else
        {
            result = "{success:'0',msg:'推送失败 末取到status',data:''}";
        }
        context.Response.Write(result);
    }

    /// <summary>
    /// 发送房源至房友在线
    /// </summary>
    /// <param name="model"></param>
    /// <param name="context"></param>
    private void SendHouseToSinaFYZX(Chenxin.Lib.House.Entity.House_BaseInfo model, HttpContext context)
    {
        string SinaUserId = context.Request["SinaUserId"];
        string SinaHouseTitle = context.Request["SinaHouseTitle"];
        if (SinaUserId == null || SinaUserId == "" || SinaUserId == "undefined")
        {
            context.Response.Write("{success:'0',msg:'请输入用户ID',data:''}");
            return;
        }
        if (SinaHouseTitle == null || SinaHouseTitle == "" || SinaHouseTitle == "undefined")
        {
            context.Response.Write("{success:'0',msg:'请输入房源标题',data:''}");
            return;
        }
        string postUrl = "http://data.fangyou.com/apichenxin/upload?client_citycode=sh";
        string delUrl = "http://data.fangyou.com/apichenxin/delete?client_citycode=sh";   //暂时无用-------删除房源
        string refUrl = "http://data.fangyou.com/apichenxin/refresh?client_citycode=sh";  //暂时无用--------刷新房源
        //已经弃用  //UploadSinaHouse.WebClient w = new UploadSinaHouse.WebClient();
        int sina_result = -1;
        if (model.BusinessKind == 30)
        {
            model.BusinessKind = 10;
            sina_result = this.UploadSina(postUrl, "&xmlfile=" + UploadXML(model, SinaUserId, SinaHouseTitle) + "");
            model.BusinessKind = 20;
            sina_result = this.UploadSina(postUrl, "&xmlfile=" + UploadXML(model, SinaUserId, SinaHouseTitle) + "");
        }
        else
        {
            sina_result = this.UploadSina(postUrl, "&xmlfile=" + UploadXML(model, SinaUserId, SinaHouseTitle) + "");
        }
        if (sina_result < 0)
        {
            string msg = "";
            switch (sina_result)
            {
                case -1:
                    msg = "账号密码";
                    break;
                case -2:
                    msg = "禁止使用";
                    break;
                case -3:
                    msg = "参数格式不符";
                    break;
                case -4:
                    msg = "存取失败";
                    break;
                case -5:
                    msg = "primary key不存在";
                    break;
                case -6:
                    msg = "超过所限制的房源数量(或超过可以刷新次数)";
                    break;
                default:
                    msg = "异常：推送失败";
                    break;
            }
            result = "{success:'0',msg:'" + msg + "',data:''}";
        }
        else if (sina_result == 0)
        {
            result = "{success:'1',msg:'推送成功',data:''}";
            this.RecodSendLog(model.HouseId, model.HouseCode, model.Address, model.OprPersonId, model.OprDepartId,
                    CurrentUserInfo.UserId, CurrentUserInfo.DepartId, "房友在线", "http://sh.fangyou.com/", "", "");
        }
        context.Response.Write(result);
    }

    /// <summary>
    ///  构建上传安居客房源数据Map
    /// </summary>
    /// <param name="model">房源对象</param>
    /// <param name="userID">安居客经纪人id</param>
    /// <param name="commID">安居客小区id</param>
    /// <param name="BussinessKind">房源租售类型，10 出售 20 出租</param>
    /// <param name="hosueTitle">上传安居客房源标题</param>
    /// <returns>Map集合</returns>
    private IDictionary InsertHouseInfo(House_BaseInfo model, string userID, string commID,
        int BussinessKind, string hosueTitle)
    {
        IDictionary map = new Hashtable();
        string fitment = "";
        string style = "";
        switch (model.Fitment)
        {
            case "毛坯":
                fitment = "1";
                break;
            case "豪华装修":
                fitment = "4";
                break;
            case "精装修":
                fitment = "3";
                break;
            default:
                fitment = "2";
                break;
        }
        switch (model.HouseUse)
        {
            case "公寓":
                style = "1";
                break;
            case "新里洋房":
                style = "2";
                break;
            case "别墅":
                style = "3";
                break;
            case "老公房":
                style = "5";
                break;
            default:
                style = "4";
                break;
        }
        string room = "";
        if (model.Model_Room == null)
        {
            room += "1,";
        }
        else
        {
            room += model.Model_Room.ToString() + ",";
        }
        if (model.Model_Hall == null)
        {
            room += "1,";
        }
        else
        {
            room += model.Model_Hall.ToString() + ",";
        }
        if (model.Model_Toilet == null)
        {
            room += "1";
        }
        else
        {
            room += model.Model_Toilet.ToString();
        }
        string floor = "";
        if (model.Cur_Floor == null)
        {
            floor += "6,";
        }
        else
        {
            floor += model.Cur_Floor.ToString() + ",";
        }
        if (model.Total_Floor == null)
        {
            floor += "6";
        }
        else
        {
            floor += model.Total_Floor.ToString();
        }

        if (BussinessKind == 10)
        {
            map.Add("broker_id", userID);  //经纪人id
            map.Add("comm_id", commID);   //小区id 
            map.Add("userDefined", userID);  //小区自定义编号
            map.Add("trade_type", "1"); //交易类型 1 售 2 租
            map.Add("price", model.SalePrice_T.ToString());  //价格单位为元。目前只支持人民币。 1 二手房 - 为售价格 2 出租房 - 为每单位时间租金。(目前仅支持月为时间单位) 
            map.Add("for_lease", "1");  //是否带租约。仅对二手房(trade_type==1:售)。
            map.Add("area", model.BuildingArea.ToString());//model.BuildingArea.ToString());   //面积
            map.Add("rooms", room);  //房型
            map.Add("floor", floor);  //楼层
            map.Add("year", model.CompleteYear.ToString()); //房屋建成年份。房龄为当前年份减去建成年份
            map.Add("fitment", fitment);  // 装修情况：1毛坯 ；2普通装修；3精装修；4豪华装修
            map.Add("style", style);  //房屋类型：1公寓；2新里洋房；3别墅；4其它；5c 
            map.Add("exposure", model.Direction);   //朝向：0东；1南；2西；3北；4东南；5东北；6西南；7西北；8南北；9东西
            map.Add("title", hosueTitle); //"出售 " + model.Community);  //房源标题
            map.Add("description", "房屋配置：" + model.BaseEquip + "  " + model.Remarks);  //房源描述
            map.Add("stype", "1");  //1=出售出租中,11=待上架
        }
        if (BussinessKind == 20)
        {
            map.Add("broker_id", userID);                //经纪人id
            map.Add("comm_id", commID);                 //小区id 
            map.Add("userDefined", userID);            //小区自定义编号
            map.Add("area", model.BuildingArea.ToString());                       //面积
            map.Add("rooms", room);                   //房型      
            map.Add("price", model.RentPrice.ToString());               //价格单位为元。目前只支持人民币。 1 二手房 - 为售价格 2 出租房 - 为每单位时间租金。(目前仅支持月为时间单位) 
            map.Add("rent_deposit_and_cycle", "3,1");  // 付款方式。仅对出租房(trade_type==2:租)。目前仅支持押几付几的形式，例如'''1,3'''表示押金为一个月的price，一次付款3个月price。
            map.Add("year", model.CompleteYear.ToString());                     //房屋建成年份。房龄为当前年份减去建成年份
            map.Add("floor", floor);                        //楼层
            map.Add("fitment", fitment);                       // 装修情况：1毛坯 ；2普通装修；3精装修；4豪华装修
            map.Add("trade_type", "2");                  //交易类型 1 售 2 租
            map.Add("style", style);                       ////房屋类型：1公寓；2新里洋房；3别墅；4其它；5c 
            map.Add("exposure", model.Direction);                   //朝向：0东；1南；2西；3北；4东南；5东北；6西南；7西北；8南北；9东西
            map.Add("share_rent", model.IsGroup == true ? "1" : "0");                  //是否合租 0 否 1 是
            map.Add("title", hosueTitle);//"出租 " + model.Community);               //房源标题
            map.Add("description", "房屋配置：" + model.BaseEquip + "  " + model.Remarks);  //房源描述  可以将房屋配置和基础设施加入其中
            map.Add("stype", "1");                       //1=出售出租中,11=待上架
        }
        return map;
    }

    /// <summary>
    /// 从安居客获取小区信息和用户信息
    /// </summary>
    /// <param name="domain">安居客域名</param>
    /// <param name="uri"> 安居客地址</param>
    /// <returns>以json数据类型返回的数据字符串</returns>
    private string GetCommidOrUserid(String domain, string uri, string getType)
    {
        string result_json = string.Empty;
        HttpWebRequest req = (HttpWebRequest)
         HttpWebRequest.Create(domain + uri);
        req.Method = "GET";
        req.ContentType =
            "application/x-www-form-urlencoded;charset=utf-8";
        using (WebResponse wr = req.GetResponse())
        {
            Stream stream = wr.GetResponseStream();
            StreamReader sr = new StreamReader(stream, myEncoding);
            result_json = sr.ReadToEnd();
            //result_json = result_json.Replace("@", "");
        }
        if (getType == "community")
        {
            return result_json;
        }
        if (getType == "deleteProid")
        {
            return result_json;
        }
        //C#中解析json 下面为查找brokerid 经纪人id
        Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(result_json);
        object value;
        object id_value = "";
        if (json.TryGetValue(getType, out value))
        {
            Dictionary<string, object> comm = (Dictionary<string, object>)value;
            if (comm.TryGetValue("id", out id_value))
            {
                result_json = id_value.ToString();
            }
        }
        else
        {
            result_json = "error";
        }
        return result_json;
    }


    /// <summary>
    /// 安居客构建参数
    /// </summary>
    /// <param name="key"></param>
    /// <param name="value"></param>
    /// <returns></returns>
    private string getPostParamWithAnd(string key, string value)
    {
        String param = HttpUtility.UrlEncode(key, myEncoding) + "=" + HttpUtility.UrlEncode(value, myEncoding) + "&";
        return param;
    }


    /// <summary>
    /// 安居客执行上传房源操作
    /// </summary>
    /// <param name="domain">域名</param>
    /// <param name="uri">资源地址</param>
    /// <param name="map">房源上传数据</param>
    /// <returns>以json形式返回</returns>
    private string Execue(String domain, String uri, IDictionary map)
    {
        string str = "";
        StringBuilder sb = new StringBuilder();
        foreach (DictionaryEntry de in map)
        {
            sb.Append(getPostParamWithAnd(de.Key.ToString(), de.Value.ToString()));
        }
        /**
         * domain 域名
         * uri  资源地址
         * 
         * */
        string param = sb == null ? "" : sb.Remove(sb.Length - 1, 1).ToString();
        byte[] postBytes = Encoding.ASCII.GetBytes(param);
        HttpWebRequest req = (HttpWebRequest)
            HttpWebRequest.Create(domain + uri);
        req.Method = "POST";
        req.ContentType =
            "application/x-www-form-urlencoded;charset=utf-8";
        req.ContentLength = postBytes.Length;
        //using 立即回收
        using (Stream reqStream = req.GetRequestStream())
        {
            reqStream.Write(postBytes, 0, postBytes.Length);
        }
        using (WebResponse wr = req.GetResponse())
        {
            Stream stream = wr.GetResponseStream();
            StreamReader sr = new StreamReader(stream, myEncoding);
            str = sr.ReadToEnd();
            return str;
        }
    }

    /// <summary>
    /// 安居客上传房源图片
    /// </summary>
    /// <param name="url"></param>
    /// <param name="picAddress">图片路径</param>
    /// <param name="dataMap">图片数据通信</param>
    /// <returns>成功，失败</returns>
    private string UploadPic(string url, string picAddress, IDictionary dataMap)
    {
        // 要上传的文件
        FileStream fs = new FileStream(picAddress, FileMode.Open, FileAccess.Read);
        BinaryReader r = new BinaryReader(fs);
        //时间戳
        string strBoundary = "----------" + DateTime.Now.Ticks.ToString("x");
        byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + strBoundary + "\r\n");

        //&broker_id=5961&prop_id=8608792&photo_type=1

        //请求头部信息
        StringBuilder sb = new StringBuilder();
        foreach (DictionaryEntry data in dataMap)
        {
            sb.Append("--");
            sb.Append(strBoundary);
            sb.Append("\r\n");
            sb.Append("Content-Disposition: form-data; name=\"");
            sb.Append(data.Key.ToString());
            sb.Append("\"");
            sb.Append("\r\n\r\n");
            sb.Append(data.Value.ToString());
            sb.Append("\r\n");
        }
        sb.Append("--");
        sb.Append(strBoundary);
        sb.Append("\r\n");
        sb.Append("Content-Disposition: form-data; name=\"");
        sb.Append("file");
        sb.Append("\"; filename=\"");
        sb.Append("Test.jpg");
        sb.Append("\"");
        sb.Append("\r\n");
        sb.Append("Content-Type: ");
        sb.Append("image/jpeg");   //application/octet-stream
        sb.Append("\r\n");
        sb.Append("\r\n");
        string strPostHeader = sb.ToString();
        byte[] postHeaderBytes = Encoding.UTF8.GetBytes(strPostHeader);

        // 根据uri创建HttpWebRequest对象
        HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(url));
        httpReq.Method = "POST";

        //对发送的数据不使用缓存
        httpReq.AllowWriteStreamBuffering = false;

        //设置获得响应的超时时间（300秒）
        httpReq.Timeout = 300000;
        httpReq.ContentType = "multipart/form-data; boundary=" + strBoundary; //"application/x-www-form-urlencoded";//
        long length = fs.Length + postHeaderBytes.Length + boundaryBytes.Length;
        long fileLength = fs.Length;
        httpReq.ContentLength = length;
        String sReturnString = "";
        try
        {
            //每次上传4k
            int bufferLength = 4096;
            byte[] buffer = new byte[bufferLength];

            //已上传的字节数
            long offset = 0;

            int size = r.Read(buffer, 0, bufferLength);
            Stream postStream = httpReq.GetRequestStream();

            //发送请求头部消息
            postStream.Write(postHeaderBytes, 0, postHeaderBytes.Length);
            while (size > 0)
            {
                postStream.Write(buffer, 0, size);
                offset += size;
                size = r.Read(buffer, 0, bufferLength);
            }
            //添加尾部的时间戳
            postStream.Write(boundaryBytes, 0, boundaryBytes.Length);
            postStream.Close();

            //获取服务器端的响应
            WebResponse webRespon = httpReq.GetResponse();
            Stream s = webRespon.GetResponseStream();
            StreamReader sr = new StreamReader(s);

            //读取服务器端返回的消息
            sReturnString = sr.ReadLine();
            s.Close();
            sr.Close();
        }
        catch
        {
        }
        finally
        {
            fs.Close();
            r.Close();
        }
        return sReturnString;
    }


    /// <summary>
    /// 房友在线上传房源构建XML数据对象
    /// </summary>
    /// <param name="model">房源数据</param>
    /// <param name="sina_userid">房友在线用户id</param>
    /// <param name="sina_houseTitle">房友在线上传房源标题</param>
    /// <returns>返回操作结果</returns>
    private string UploadXML(House_BaseInfo model, string sina_userid, string sina_houseTitle)
    {
        string picUrl_Title = System.Configuration.ConfigurationManager.AppSettings["Picture.RootUrl"];
        string picUrl = "";
        List<House_PicturesInfo> pic_list = Chenxin.Lib.House.DAL.House_PicturesInfo.GetListArray("HouseId='" + model.HouseId.ToString() + "'");
        StringBuilder strb = new StringBuilder();
        string TradeType = model.BusinessKind.ToString() == "10" ? "出售" : model.BusinessKind.Value.ToString() == "20" ? "出租" : "租售";
        string SalePrice = model.BusinessKind.ToString() == "10" ? model.SalePrice_T.ToString() : "";
        string RentPrice = model.BusinessKind.ToString() == "20" ? model.RentPrice.ToString() : "";
        string RentType = model.BusinessKind.ToString() == "20" ? model.IsGroup.ToString() == "true" ? "合租" : "整租" : "";
        string PaymentReq = model.PayMode == "其他" ? "面议" : model.PayMode.Replace("租", "付");
        strb.Append("<?xml version='1.0' encoding='UTF-8'?>");//<!--*号为必填项-->
        strb.Append("<HouseInfo>");
        strb.Append("<PropertyID>" + model.HouseId + "</PropertyID>");  //<!--*贵公司房源primary key-->
        strb.Append("<Username>" + sina_userid + "</Username>"); //<!--*房友在线用户id-->
        strb.Append("<TradeType>" + TradeType + "</TradeType>"); //<!--*交易类型(出售，出租，租售)-->
        strb.Append("<SalePrice>" + SalePrice + "</SalePrice>");  //<!-- *出售价格(数字）单位：元-->
        strb.Append("<RentPrice>" + RentPrice + "</RentPrice>");  //<!-- *（出租必填）出租价格(数字）单位：元/月-->
        strb.Append("<UsableArea></UsableArea>");  //<!-- 使用面积(数字)-->
        strb.Append("<Furniture>" + model.BaseEquip + "</Furniture>");    //<!-- 家具配套-->
        strb.Append("<RentType>" + RentType + "</RentType>");   //<!-- 租凭方式(整租/合租)-->
        strb.Append("<RenterGender></RenterGender>");   //<!-- 租凭人的性别（性别不限/限男性/限女性）-->
        strb.Append("<MinRentPeriod></MinRentPeriod>");   //<!-- 最短租期（不限/1月/3月/半年/1年/2年）-->
        strb.Append("<MaxRentPeriod></MaxRentPeriod>");  //<!-- 最长租期（不限/1月/3月/半年/1年/2年）-->
        strb.Append("<PaymentReq>" + PaymentReq + "</PaymentReq>");    //<!-- 付款要求（月付/季付/半年付/年付/面议）-->
        strb.Append("<DepositReq></DepositReq>");  //<!-- 押金要求（半月租金/一月租金/两月租金/一季租金/面议）-->
        strb.Append("<HouseCode></HouseCode>");   //<!-- 房源编号\内部编号-->
        strb.Append("<HouseTitle>" + sina_houseTitle + "</HouseTitle>");   //<!--*房源标题（例如：性价比高,地铁沿线,交通便利,配套齐全）-->
        strb.Append("<HouseAddress>" + model.Address + "</HouseAddress>");   //<!--*房源地址-->
        strb.Append("<BuildingArea>" + model.BuildingArea.ToString() + "</BuildingArea>");  //<!--*建筑面积-->
        strb.Append("<CommunityName>" + model.Community + "</CommunityName>");   //<!--*小区名称-->
        strb.Append("<District>" + model.Region + "</District>");   //<!-- *区域-->
        strb.Append("<Block>" + model.Block + "</Block>");   //<!-- 板块-->
        strb.Append("<BuildingType>" + model.BuildingType + "</BuildingType>");  //	<!-- 建筑形态（多层/多层复式/多层跃式/高层/高层复式/高层跃式/小高层/独体别墅/联体别墅/双拼别墅/裙楼/四合院）-->
        strb.Append("<PropertyType>" + model.HouseUse + "</PropertyType>");   //	<!-- 物业类型（公寓/别墅/办公楼/商铺/厂房/商住/车位/其他）-->
        strb.Append("<Direction>" + model.Direction + "</Direction>");  //	<!-- 朝向-->
        strb.Append("<CompleteDate>" + model.CompleteYear.ToString() + "</CompleteDate>");  //<!-- 竣工日期（年份）如2003，2004等-->
        strb.Append("<Model_Room>" + model.Model_Room.ToString() + "</Model_Room>");  //	<!-- *房型：室(数字)如1，2，3等-->
        strb.Append("<Model_Hall>" + model.Model_Hall.ToString() + "</Model_Hall>");   //	<!-- 房型：厅室(数字)如1，2，3等-->
        strb.Append("<Model_Toilet>" + model.Model_Toilet.ToString() + "</Model_Toilet>");  //	<!-- 房型：卫室(数字)如1，2，3等-->
        strb.Append("<LookHouse></LookHouse>");   //	<!-- 看房情况（直接 预约 有匙 借匙 其他）-->
        strb.Append("<HouseActuality></HouseActuality>");   //	<!-- 房屋现状（空房 业主住 租房住 其它）-->
        strb.Append("<PropertyRight>" + model.Property + "</PropertyRight>");   //	<!-- 产权情况（商品房/房改房/经济适用房/集体房/军产房/其他）-->
        strb.Append("<PropertyCode></PropertyCode>");  //	<!-- 产证编号-->
        strb.Append("<PropertyManagementFee></PropertyManagementFee>");  //	 <!-- 物业管理费(数字)单位：元/月/平方米-->
        strb.Append("<TotalFloor>" + model.Total_Floor.ToString() + "</TotalFloor>");   //  <!-- *层高(数字)-->
        strb.Append("<CurFloor>" + model.Cur_Floor.ToString() + "</CurFloor>");  //  <!-- *当前楼层(数字)-->
        strb.Append("<Fitment>" + model.Fitment + "</Fitment>");   //	<!-- 装修情况（毛坯/清水/简装/中装/精装/豪装）-->
        strb.Append("<CarPlace></CarPlace>");   //<!-- 车位情况-->
        strb.Append("<Memo>" + model.Remarks + "</Memo>");  //<!--*房源详情描述-->
        strb.Append("<HousePic>");  //<!—房源图片-->		<!—图片类型1:房型图,2:室内图,3:小区图-->
        strb.Append("<Pic><Type>1</Type><File>http://images8.anjukestatic.com/community/20091118/34/13/37/28/34133728/420x420.jpg</File></Pic>");
        string picType = "";
        foreach (House_PicturesInfo pic in pic_list)
        {
            switch (pic.PicType)
            {//1:房型图,2:室内图,3:小区图
                case "房型图":
                    picType = "1";
                    break;
                case "室内图":
                    picType = "2";
                    break;
                case "室外图":
                    picType = "3";
                    break;
            }
            picUrl = picUrl_Title + pic.MarkedUrl;
            strb.Append("<Pic><Type>" + picType + "</Type><File>" + picUrl + "</File></Pic>");  //		<!—图片链接-->
        }
        strb.Append("</HousePic >");
        strb.Append("</HouseInfo>");
        return strb.ToString();
    }

    /// <summary>
    /// 上传房友在线
    /// </summary>
    /// <param name="url">地址</param>
    /// <param name="data">数据</param>
    /// <returns>操作结果</returns>
    private int UploadSina(string url, string data)
    {
        string backstr = "";
        int out_temp = -1;
        try
        {
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            byte[] requestBytes = myEncoding.GetBytes(data);
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = requestBytes.Length;
            Stream requestStream = req.GetRequestStream();
            requestStream.Write(requestBytes, 0, requestBytes.Length);
            requestStream.Close();
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            StreamReader sr = new StreamReader(res.GetResponseStream(), myEncoding);
            backstr = sr.ReadToEnd();
            sr.Close(); res.Close();
            Int32.TryParse(backstr, out out_temp);
        }
        catch (Exception err)
        {
            out_temp = -10;
        }
        return out_temp;
    }



    private IDictionary BuildCityReHouseDic(House_BaseInfo model, string userID,
        string userPwd, string hosueTitle)
    {
        string Lease = model.BusinessKind.ToString() == "20" ? "1" : "0";
        string OutType = model.BusinessKind.ToString() == "10" ? "1" : "0";
        decimal Rental = model.RentPrice == null ? 0 : model.RentPrice.Value;
        decimal Price = model.SalePrice_T == null ? 0 : model.SalePrice_T.Value / 10000;
        string PayType = model.PayMode == null ? "" : model.PayMode;
        int RentType = model.BusinessKind.ToString() == "20" ? model.IsGroup == true ? 1 : 0 : 0;
        string Facilities = model.BaseEquip == null ? "" : model.BaseEquip;
        int Old = model.CompleteYear == null ? 1 : (DateTime.Now.Year - model.CompleteYear.Value);
        int Room = model.Model_Room == null ? 1 : model.Model_Room.Value;
        int Office = model.Model_Hall == null ? 1 : model.Model_Hall.Value;
        int Toilet = model.Model_Toilet == null ? 1 : model.Model_Toilet.Value;
        int Floor = model.Total_Floor == null ? 6 : model.Total_Floor.Value;
        int TheFloor = model.Cur_Floor == null ? 1 : model.Cur_Floor.Value;
        IDictionary map = new Hashtable();
        List<House_PicturesInfo> pic_list = Chenxin.Lib.House.DAL.House_PicturesInfo.GetListArray("HouseId='" + model.HouseId.ToString() + "'");
        string TitlePic = "", TypePic = "", InnerPic = "", picUrl_Title = System.Configuration.ConfigurationManager.AppSettings["Picture.RootUrl"];
        int countInnerPIc = 0;
        foreach (House_PicturesInfo pic in pic_list)
        {
            switch (pic.PicType)
            {//1:房型图,2:室内图,3:小区图
                case "房型图":
                    TitlePic = picUrl_Title + pic.MarkedUrl;
                    break;
                case "室内图":
                    if (countInnerPIc < 4)
                    {
                        if (countInnerPIc == 3)
                        {
                            InnerPic += picUrl_Title + pic.MarkedUrl;
                        }
                        else
                        {
                            InnerPic += picUrl_Title + pic.MarkedUrl + ",";
                        }
                        ++countInnerPIc;
                    }
                    break;
                case "室外图":
                    TypePic = picUrl_Title + pic.MarkedUrl;
                    break;
            }
        }
        map.Add("UserID", userID);
        map.Add("UserPwd", userPwd);
        map.Add("Title", hosueTitle);
        map.Add("Region", model.Region);
        map.Add("Block", model.Block);
        map.Add("HouseID", model.HouseCode);
        map.Add("Acreage", model.BuildingArea);
        map.Add("Room", Room);
        map.Add("Office", Office);
        map.Add("Toilet", Toilet);
        map.Add("Price", Price);
        map.Add("Floor", Floor);
        map.Add("TheFloor", TheFloor);
        map.Add("Old", Old);
        map.Add("Lease", Lease);
        map.Add("Decoration", model.Fitment);
        map.Add("HouseType", model.HouseUse);
        map.Add("Direction", model.Direction);
        map.Add("OutType", OutType);
        map.Add("Rental", Rental);
        map.Add("PayType", PayType);
        map.Add("Sharing", RentType);
        map.Add("Facilities", Facilities);
        map.Add("HousingName", model.Community);
        map.Add("HousingAdd", model.Address);
        map.Add("BuildAdd", model.BuildingName);
        map.Add("TitlePic", TitlePic);
        map.Add("TypePic", TypePic);
        map.Add("InnerPic", InnerPic);
        return map;
    }

    /// <summary>
    /// 推送CityReHouse （判断楼盘字典）
    /// </summary>
    /// <param name="model"></param>
    /// <param name="context"></param>
    private void AddCItyReHouseInfo(House_BaseInfo model, HttpContext context)
    {
        string cityReHouseConn = System.Configuration.ConfigurationManager.AppSettings["SendHouseToCityReHouseConn"];
        string sqlStr = "select EMP_ID from EMPTab where rtrim(ltrim(EMP_ID))='" + context.Request["CityReHouseUserId"].Trim() + "' and rtrim(ltrim(EMP_Pwd))='" + context.Request["CityReHouseHousePwd"] + "' ;";
        SqlConnection conn = new SqlConnection(cityReHouseConn);
        SqlCommand cmd = new SqlCommand(sqlStr, conn);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        if (dt.Rows.Count == 0)
        {
            context.Response.Write("{success:'0',msg:'请输入正确的用户ID和密码',data:''}");
            return;
        }
        sqlStr = "select ID from HouseDictionary where rtrim(ltrim(HousingName))='" + model.Community.Trim() + "' ";
        cmd.CommandText = sqlStr;
        adp.SelectCommand = cmd;
        dt = new DataTable();
        adp.Fill(dt);
        int successCount = 0;
        int commID = 0;
        if (dt.Rows.Count == 0)
        {
            sqlStr = "insert into HouseDictionary (HousingName,Initials,Area,Section,HousingAdd,Auditing) values('" + model.Community + "','" + this.GetChineseSpell(model.Community) + "','" + model.Region + "','" + model.Block + "','" + model.Address + "','False') ";
            cmd.CommandText = sqlStr;
            conn.Open();
            int result = cmd.ExecuteNonQuery();
            conn.Close();
            if (result > 0)
            {
                sqlStr = "select top 1 ID from dbo.HouseDictionary order by ID desc";
                cmd.CommandText = sqlStr;
                adp.SelectCommand = cmd;
                dt = new DataTable();
                adp.Fill(dt);
                commID = Convert.ToInt32(dt.Rows[0][0]);
            }
        }
        else
        {
            commID = Convert.ToInt32(dt.Rows[0][0]);
        }
        successCount = this.InsertCityReHouseHouseTab(model, commID, conn, cmd, context);
        conn.Dispose();
        cmd.Dispose();
        if (successCount == 0)
        {
            context.Response.Write("{success:'0',msg:'推送失败,建议到CityReHouse手工推送',data:''}");
            return;
        }
        context.Response.Write("{success:'1',msg:'推送成功',data:''}");

    }

    /// <summary>
    /// 推送CityReHouse （Insert HouseTab信息--如果已存在则update）
    /// </summary>
    /// <param name="model"></param>
    /// <param name="context"></param>
    private int InsertCityReHouseHouseTab(Chenxin.Lib.House.Entity.House_BaseInfo model, int commID,
        SqlConnection conn, SqlCommand cmd, HttpContext context)
    {
        StringBuilder sqlSbl = new StringBuilder();
        cmd = new SqlCommand("select ID from HouseTab where HouseID='" + model.HouseCode + "' ", conn);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        string Lease = model.BusinessKind.ToString() == "20" ? "True" : "False";
        string OutType = model.BusinessKind.ToString() == "10" ? "True" : "False";
        decimal Rental = model.RentPrice == null ? 0 : model.RentPrice.Value;
        decimal Price = model.SalePrice_T == null ? 0 : model.SalePrice_T.Value;
        string PayType = model.PayMode == null ? "" : model.PayMode;
        int RentType = model.BusinessKind.ToString() == "20" ? model.IsGroup == true ? 1 : 0 : 0;
        string Facilities = model.BaseEquip == null ? "" : model.BaseEquip;
        int Old = model.CompleteYear == null ? 1 : (DateTime.Now.Year - model.CompleteYear.Value);
        int Room = model.Model_Room == null ? 1 : model.Model_Room.Value;
        int Office = model.Model_Hall == null ? 1 : model.Model_Hall.Value;
        int Toilet = model.Model_Toilet == null ? 1 : model.Model_Toilet.Value;
        int Floor = model.Total_Floor == null ? 6 : model.Total_Floor.Value;
        int TheFloor = model.Cur_Floor == null ? 1 : model.Cur_Floor.Value;
        List<House_PicturesInfo> pic_list = Chenxin.Lib.House.DAL.House_PicturesInfo.GetListArray("HouseId='" + model.HouseId.ToString() + "'");
        string TitlePic = "", TypePic = "", InnerPic = "", picUrl_Title = System.Configuration.ConfigurationManager.AppSettings["Picture.RootUrl"];
        int countInnerPIc = 0;
        foreach (House_PicturesInfo pic in pic_list)
        {
            switch (pic.PicType)
            {//1:房型图,2:室内图,3:小区图
                case "房型图":
                    TitlePic = picUrl_Title + pic.MarkedUrl;
                    break;
                case "室内图":
                    if (countInnerPIc < 4)
                    {
                        if (countInnerPIc == 3)
                        {
                            InnerPic += picUrl_Title + pic.MarkedUrl;
                        }
                        else
                        {
                            InnerPic += picUrl_Title + pic.MarkedUrl + ",";
                        }
                        ++countInnerPIc;
                    }
                    break;
                case "室外图":
                    TypePic = picUrl_Title + pic.MarkedUrl;
                    break;
            }
        }
        if (dt.Rows.Count == 0)
        {
            sqlSbl.Append("insert into HouseTab (HousingID,HouseID,Acreage,Room,Office,Toilet,Price,Floor,TheFloor,Old,Lease,");
            sqlSbl.Append("Decoration,HouseType,Direction,Title,TitlePic,TypePic,InnerPic,Published,Recommended,EMP_ID,ClickRate,");
            sqlSbl.Append("OutType,Rental,PayType,Sharing,Facilities,HousingName,HousingAdd,Business,IsNew,IsHurry,BuildAdd,FilingTime) ");
            sqlSbl.Append("values (" + commID + ",'" + model.HouseCode + "'," + model.BuildingArea + "," + Room + "");
            sqlSbl.Append("," + Office + "," + Toilet + "," + Price + "," + Floor + "," + TheFloor + "," + Old + "");
            sqlSbl.Append(", '" + Lease + "','" + model.Fitment + "','" + model.HouseUse + "','" + model.Direction + "'");
            sqlSbl.Append(",'" + context.Request["CityReHouseHouseTitle"] + "','" + TitlePic + "','" + TypePic + "','" + InnerPic + "','True','False','" + context.Request["CityReHouseUserId"] + "','0','" + OutType + "'," + Rental + "");
            sqlSbl.Append(",'" + PayType + "'," + RentType + ",'" + Facilities + "','" + model.Community + "','" + model.Address + "','False','True','False','" + model.BuildingName + "','" + DateTime.Now.ToString() + "')");
        }
        else
        {
            sqlSbl.Append("update HouseTab set Acreage=" + model.BuildingArea + ",Room=" + Room + ",Office=" + Office + "");
            sqlSbl.Append(",Toilet=" + Toilet + ",Price=" + Price + ",Floor=" + Floor + ",TheFloor=" + TheFloor + ",Old=" + Old + ",Lease='" + Lease + "'");
            sqlSbl.Append(",Decoration='" + model.Fitment + "',HouseType='" + model.HouseUse + "',Direction='" + model.Direction + "'");
            sqlSbl.Append(",Title='" + context.Request["CityReHouseHouseTitle"] + "',EMP_ID='" + context.Request["CityReHouseUserId"] + "'");
            sqlSbl.Append(",OutType='" + OutType + "',Rental=" + Rental + ",PayType='" + PayType + "',Sharing=" + RentType + ",Facilities='" + Facilities + "'");
            sqlSbl.Append(",HousingName='" + model.Community + "',HousingAdd='" + model.Address + "',BuildAdd='" + model.BuildingName + "',UpdateTime='" + DateTime.Now.ToString() + "' ");
            sqlSbl.Append("where ID=" + dt.Rows[0]["ID"].ToString() + " ");
        }
        cmd.CommandText = sqlSbl.ToString();
        conn.Open();
        int execueCount = cmd.ExecuteNonQuery();
        conn.Close();
        return execueCount;
    }

    /// <summary>
    /// 取楼盘名的首字母拼音
    /// </summary>
    /// <param name="strText"></param>
    /// <returns></returns>
    private string GetChineseSpell(string strText)
    {
        int len = strText.Length;
        string myStr = "";
        for (int i = 0; i < len; i++)
        {
            myStr += getInitial(strText.Substring(i, 1));
        }
        return myStr;
    }

    private string getInitial(string cnChar)
    {
        byte[] arrCN = Encoding.Default.GetBytes(cnChar);
        if (arrCN.Length > 1)
        {
            int area = (short)arrCN[0];
            int pos = (short)arrCN[1];
            int code = (area << 8) + pos;
            int[] areacode = { 45217, 45253, 45761, 46318, 46826, 47010, 47297, 47614, 48119, 48119, 49062, 49324, 49896, 50371, 50614, 50622, 50906, 51387, 51446, 52218, 52698, 52698, 52698, 52980, 53689, 54481 };
            for (int i = 0; i < 26; i++)
            {
                int max = 55290;
                if (i != 25) max = areacode[i + 1];
                if (areacode[i] <= code && code < max)
                {
                    return Encoding.Default.GetString(new byte[] { (byte)(65 + i) });
                }
            }
            return "*";
        }
        else return cnChar;
    }

    /// <summary>
    /// 记录推送房源日志信息
    /// </summary>
    /// <param name="opruserid">房源所有人</param>
    /// <param name="opruserdepartid">房源所部门</param>
    /// <param name="senduserid">推送人</param>
    /// <param name="senduserdepartid">推送人部门</param>
    /// <param name="sendtarget">推送目标</param>
    /// <param name="sendtargeturl">推送目标地址</param>
    private void RecodSendLog(Guid houseid, string housecode, string houseaddress, Guid opruserid, Guid opruserdepartid,
        Guid senduserid, Guid senduserdepartid, string sendtarget, string sendtargeturl, string sendAjkReturnHouseId, string sendAjkReturnCummId)
    {
        HouseSendLog housesend = new HouseSendLog();
        housesend.RecordId = Guid.NewGuid();
        housesend.HouseId = houseid;
        housesend.HouseCode = housecode;
        housesend.HouseAddress = houseaddress;
        housesend.OprUserId = opruserid;
        housesend.OprDepartId = opruserdepartid;
        housesend.SendUserId = senduserid;
        housesend.SendUserDepartId = senduserdepartid;
        housesend.SendTarget = sendtarget;
        housesend.SendTargetUrl = sendtargeturl;
        housesend.SendAjkReturnHouseId = sendAjkReturnHouseId;
        housesend.SendAjkReturnCummId = sendAjkReturnCummId;
        Chenxin.Lib.House.BLL.HouseSendLog.Add(housesend);
    }

    /// <summary>
    /// 根据HouseId获取安居客对应HouseId,以判断是否进行更新
    /// </summary>
    /// <param name="houseid"></param>
    /// <returns></returns>
    private Dictionary<string, string> GetAjkHouseIdBySendLog(string houseid, string ajkCummid)
    {
        Dictionary<string, string> dic = new Dictionary<string, string>();
        string strWhere = "HouseId='" + houseid + "' and SendTarget='安居客' and SendAjkReturnCummId='" + ajkCummid + "' ";
        DataSet ds = Chenxin.Lib.House.BLL.HouseSendLog.GetList(strWhere);
        if (ds.Tables.Count > 0)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                dic["AjkCummId"] = ds.Tables[0].Rows[0]["SendAjkReturnCummId"].ToString();
                dic["AjkHouseId"] = ds.Tables[0].Rows[0]["SendAjkReturnHouseId"].ToString();
                return dic;
            }
        }
        return dic;
    }

    
}